package com.construction_Safety.quartz.task;

import org.springframework.stereotype.Component;
import com.construction_Safety.common.utils.StringUtils;
import com.construction_Safety.common.utils.spring.SpringUtils;
import java.lang.reflect.Method;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }
    public void resetRegionStatus()
    {
        System.out.println("开始执行区域状态重置任务：将所有区域状态置为待维修(1)");
        try
        {
            Class<?> controllerClazz = Class.forName("com.construction_Safety.region.controller.CRegionController");
            Object controllerBean = SpringUtils.getBean(controllerClazz);
            if (controllerBean == null)
            {
                System.out.println("未获取到 CRegionController Bean，任务终止");
                return;
            }
            Method method = controllerClazz.getMethod("resetAllRegionsToPendingRepair");
            Object result = method.invoke(controllerBean);
            System.out.println("区域状态重置任务已触发，返回结果：" + String.valueOf(result));
        }
        catch (Exception e)
        {
            System.out.println("区域状态重置任务执行异常：" + e.getMessage());
            e.printStackTrace();
        }
    }
}
